const initialState = {
  page: 1,
  per_page: 10,
  list: [],
  total_count: 0,
  channels: [],
}
const article = (state = initialState, action) => {
  if (action.type === 'article/getChannels') {
    return {
      ...state,
      channels: action.payload,
    }
  }

  if (action.type === 'article/getList') {
    const { page, per_page, results: list, total_count } = action.payload
    return {
      ...state,
      page,
      per_page,
      list,
      total_count,
    }
  }

  return state
}

export default article
